<?php
//echo $extra;
	if ($extra == 'NSW')
	{
		$type_id = JOBTYPE_NSW;
		$city_id = false;
		$gid = 1;
	}
	else if ($extra == 'VIC')
	{
		$type_id = JOBTYPE_VIC;
		$city_id = false;
		$gid = 6;
	}
	else if ($extra == 'QLD')
	{
		$type_id = JOBTYPE_QLD;
		$city_id = false;
		$gid = 2;
	}
		else if ($extra == 'SA')
	{
		$type_id = JOBTYPE_SA;
		$city_id = false;
		$gid = 5;
	}
		else if ($extra == 'NT')
	{
		$type_id = JOBTYPE_NT;
		$city_id = false;
		$gid = 3;
	}
		else if ($extra == 'WA')
	{
		$type_id = JOBTYPE_WA;
		$city_id = false;
		$gid = 4;
	}
		else if ($extra == 'TAS')
	{
		$type_id = JOBTYPE_TAS;
		$city_id = false;
		$gid = 7;
	}
		else if ($extra == 'ACT')
	{
		$type_id = JOBTYPE_ACT;
		$city_id = false;
		$gid = 8;
	}
	else
	{
		$type_id = false;
		$city_id = false;
	}
	
	//echo $type_id;
//echo $id;
	if($type_id && $id != 'all')
	{
		if ($job->IsValidCategory($id))
		{
			$jobCount =  $job->CountJobs($id, $type_id);
			$smarty->assign('jobs_count', $jobCount);
		}
		else
		{
			redirect_to(BASE_URL . 'page-unavailable/');
			exit;
		}
	}
	
	if (!$type_id && $id != 'all')
	{
		if ($job->IsValidCategory($id))
		{
			
			$jobCount =  $job->CountJobs($id);
			$smarty->assign('jobs_count', $jobCount);
		}
		else
		{
			redirect_to(BASE_URL . 'page-unavailable/');
			exit;
		}
	}
	else if($id == 'all')
	{
		$jobCount =  $job->CountJobs();
		$smarty->assign('jobs_count', $jobCount);
	}
	
	$paginatorLink = BASE_URL . "realestates/$id";
	
	if (isset($extra))
		$paginatorLink .= "/$extra";
		
		
		//STATE//
		$asd = $db->QueryArray("SELECT  gamename  FROM property_state_list WHERE id=$gid  ORDER BY gamename ASC");
		if(!is_array($asd) || count($asd)<=0) {
		//if(!$catename=) {
echo 'WRONG ID';
exit;
}


///////////////MY


	$suburbs = array();
	$sanitizer = new Sanitizer();
	
	$sql = "SELECT * FROM property_city_list  
								WHERE isgamearea=1 AND gameid=$gid";

	//echo $sql;
	$comps = $db->QueryArray($sql);
	$submenu_name=array();
	foreach ($comps as $company)
	{

		
		//$suburbs[] = array('name' => $company['company'], 
		//                     'varname' => $sanitizer->sanitize_title_with_dashes($company['company']), 
		///                     'count' => $nr, 
		 //                    'tag_height' => $tag_height);
		 	$id1 = $company['id'];                     
		$submenu_name[$id1]= $company['gamearea'];
	}
	

	
	$citys=array();		

if(count($submenu_name)>0){
foreach( $submenu_name as $kk => $vv ){ 
	$sql = "SELECT * FROM property_city_list WHERE gamearea=$kk ORDER BY gamegroup ASC";
	$comps = $db->QueryArray($sql);
													
foreach ($comps as $companya)
	{
	$citys[$kk][] = $companya['gamegroup'];	 
}
}
}
	
	
	//print_r($submenu_name);
	
	
	

	$smarty->assign('submenu_name',$submenu_name);
	$smarty->assign('citys', $citys);
	
	foreach($submenu_name as $kkk => $vvv) {   
          			   $citys_arr[$kkk] = implode("<br>",$citys[$kkk]);//"";
          			  }
	$smarty->assign('citys_arr',$citys_arr);
	$smarty->assign('extra',$extra);
	$smarty->assign('id',$id);
	
				$smarty->assign('property_array',$property_array);	
	$smarty->assign('property_array2',$property_array2);
	
	$smarty->assign('suburbs_count', count($citys));
	$html_title = $translations['suburbs']['page_title'];
	$template = 'cityselect.tpl';
?>